package com.key.controller.admin.analysisReport;

import com.github.pagehelper.PageHelper;
import com.key.common.R;
import com.key.common.vo.AssetHistoryVO;
import com.key.common.vo.AssetListVO;
import com.key.common.vo.AssetListVO1;
import com.key.common.vo.DetailedTreatmentVO;
import com.key.service.AssetHistoryService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Author：朕
 * @Package：com.key.controller.admin.analysisReport
 * @Project：ams_system
 * @name：AssetHistory
 * @Date：2023/2/18 9:09
 * @Filename：AssetHistory
 */
@Controller
@Api(value = "分析报表",tags = "资产履历的API")
@RequestMapping("/AssetHistory")
public class AssetHistoryController {

    @Autowired
    private AssetHistoryService assetHistoryService;



    @RequestMapping(value = "/findAssetHistoryList1",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询资产详情",notes = "",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",paramType = "query",dataType = "int",required = true),
  })
    public R findAssetHistoryList1(Integer currentPage,Integer pageSize){
        R r = new R();
        PageHelper.startPage(currentPage,pageSize);
        List<AssetHistoryVO> assetHistoryVOS = assetHistoryService.findAssetHistory1();
        if(assetHistoryVOS.size()>0){
            r.setCode(200);
            r.setMsg("显示成功");
            r.setData(assetHistoryVOS);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("显示失败");
            return r;
        }
    }



    @RequestMapping(value = "/findAssetHistoryList2",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "资产处理详情",notes = "资产Id",httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "assetId",value = "资产Id",paramType = "query",dataType = "int",required = true),
   })
    public R findAssetHistoryList2(Integer assetId){
        R r = new R();
        List<DetailedTreatmentVO> map = assetHistoryService.findAssetHistory2(assetId);

        if(map.size()>0){
            r.setCode(200);
            r.setMsg("显示成功");
            r.setData(map);
            return r;

        }else{
            r.setCode(500);
            r.setMsg("显示失败");
            return r;
        }
    }



    @RequestMapping(value = "/findAssetHistoryByDate",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "根据资产处理详情日期显示资产清单",notes = "时间和资产Id",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Date",value = "yyyy-MM-dd",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "Id",value = "资产Id",paramType = "query",dataType = "String",required = true)
    })
    public R findAssetHistoryByDate(String Date,Integer Id) {
        R r = new R();
        List<List> assetHistoryVOS = assetHistoryService.findAssetHistoryDT(Date,Id);
        if (assetHistoryVOS.size() > 0) {
            r.setCode(200);
            r.setMsg("显示成功");
            r.setData(assetHistoryVOS);
            return r;
        } else {
            r.setCode(500);
            r.setMsg("显示失败");
            return r;
        }
    }

    @ApiOperation(value = "根据高级搜索查询资产履历",notes = "根据高级搜索查询所有资产履历列表",httpMethod = "get", response = R.class)
    @RequestMapping(value = "/findAssetHistoryByAnd",method = RequestMethod.GET)
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "asd",value = "查询数据",paramType = "query",dataType = "String",required = true),
    })
    public R findAssetHistoryByAnd(String asd){
        R r = new R();
        List<AssetHistoryVO> assetListVO1s = assetHistoryService.findAssetHistoryByAnd(asd);
        if(assetListVO1s.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(assetListVO1s);
            System.out.println("200");
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            System.out.println("500");
            return r;
        }
    }


}

